<style type="text/css">
.templatedetail{
	margin:20px;
}
.templateaddiframe{
	display:none;
}
.templateadd{
	display:none;
}
.templateadd label{
	display:block;
	margin:10px 20px;
}
.templateadd input{
	width:230px;
}
.templateadd button{
	margin:0px 20px;
}
</style>
<script type="text/javascript">
$(document).ready(function(e) {
	$('.templatedetail table span').click(function(e){
		input_edit(this,'system/template!save.action');
	});
	dialog('.templateadd',{
		autoOpen:false,
		modal:true,
		resizable:false,
		title:'更新模板文件',
		width:400
	});
});
function checkFile(){
	if(checkForm($('.templateadd *[name]'))){
		setTimeout(function(){
			$(window.frames["uploadtemplate"].document).ready(function(e) {
				$( ".loading" ).dialog('close');
				var rs=$(window.frames["uploadtemplate"].document).find('body').text()
				var data={};
				try{
					data= JSON.parse(rs);
				}catch(e){
					data=false;
				}
				if(data){
					if(data.code==1){
						/*alert('上传成功！')*/
						$('.templateadd').dialog('close');
						goPage('system/template!detail.action?id='+data.id,'#main')
					}else{
						alert(data.msg);
					}
				}else{
					alert('上传失败！');
				}
			});
		},500);
		$( ".loading" ).dialog('open');
		return true;
	}else{
		return false;
	}
}
</script>
<div class="templatedetail">
  <table class='tablestyle1'>
    <caption>模板信息</caption>
    <tr>
      <th class="col2">编号</th>
      <td>${template._id}</td>
    </tr>
    <tr>
      <th class="col2">角色名称</th>
      <td><span type="text" regx="${check.description}" name="description" id="${template._id}">${template.description}</span></td>
    </tr>
    <tr>
      <th class="col2">上传时间</th>
      <td>${template.created?datetime}</td>
    </tr>
    <tr>
      <th>操作</th>
      <td><a href="javascript:void(0)" onClick="$('.templateadd').dialog('open')">更换模板</a>&nbsp;&nbsp;<a href="system/template!download.action?id=${template._id}" target="_blank">下载模板</a></td>
    </tr>
  </table>
  <iframe class="templateaddiframe" src="" name="uploadtemplate"></iframe>
  <div class="templateadd">
  <form action="system/template!upload.action" target="uploadtemplate" enctype="multipart/form-data" method="post" onSubmit="checkFile()">
    <input name="id" type="hidden" value="${template._id}" /></label>
    <label>文件：<input name="upfile" regx="${check.file}" type="file" /></label>
    <label><button type="submit">上传</button><button type="button" onClick="$('.templateadd').dialog('close');return false">取消</button></label>
  </form>
  </div>
</div>